<template>
	<view>
		<view class="order-content">
			<view class="content-item">
				<text class="item-name">访客姓名：</text>
				<text>{{ detail.name}}</text>
				<!-- <text>{{ticketDetail['工单编号']}}</text> -->
			</view>
			<view class="content-item">
				<text class="item-name">访客身份证：</text>
				<view style="word-break: break-all; flex: 1">{{
		      detail.personId
		    }}</view>
				<!-- <text>{{ticketDetail['联系人姓名']}}</text> -->
			</view>
			<view class="content-item">
				<text class="item-name">访客手机号：</text>
				<text>{{ detail.mobile }}</text>
			</view>
			<!-- <view class="content-item">
				<text class="item-name">访客车牌号：</text>
				<view style="word-break: break-all; flex: 1">{{
		      detail.licensePlate
		    }}</view>
			</view> -->
			<!-- <view class="content-item">
				<text class="item-name">访客居住地址：</text>
				<view style="word-break: break-all; flex: 1">{{
		      detail.address
		    }}</view>
			</view> -->
			<view class="content-item">
				<text class="item-name">来访事由：</text>
				<view style="word-break: break-all; flex: 1">{{
		      detail.visitPurpose
		    }}</view>
			</view>
			<view class="content-item">
				<text class="item-name">开始时间：</text>
				<view style="word-break: break-all; flex: 1">{{
		      detail.startTime | transferTime
		    }}</view>
			</view>
			<view class="content-item">
				<text class="item-name">到期时间:</text>
				<text> {{detail.expiredTime | transferTime}}</text>
			</view>
			<view v-if="detail.remarks" class="content-item">
				<text class="item-name">备注:</text>
				<view style="word-break: break-all; flex: 1"> {{detail.remarks}}</view>
			</view>
			<view class="content-item">
				<text class="item-name">访客人脸照片:</text>
				<van-image fit="cover" width="110" height="110" :src="detail.pictureUrl" />
			</view>
			<view class="content-item">
				<text class="item-name">审批结果:</text>
				<text :style="{color: approveType[detail.approved]}">{{ detail.approved ? '已通过': '未通过' }}</text>
				<!-- <view  style="word-break: break-all; flex: 1">
		      {{ types['巡检结果'][record['巡检结果']] }}</view
		    > -->
			</view>
			<button @click="approve" class="approve-btn">{{ detail.approved ? '审批不通过' :'审批通过' }}</button>
		</view>
	</view>
</template>

<script>
	import dayjs from 'dayjs'
	export default {
		data() {
			return {
				detail: {},
				approveType: {
					true: '#43CC46',
					false: '#fb2d2d'
				}
			}
		},
		onLoad(options) {
			this.detail = JSON.parse(options.item)
		},
		methods: {
			approve() {
				uni.showLoading({
					mask: true
				})
				this.detail.projId = uni.getStorageSync('userInfo').projId
				this.detail.approved = !this.detail.approved
				this.$http.post('external/face/user/update', this.detail).then(res => {
					if (res.code === 10000) {
						uni.navigateTo({
							url: '../success/success'
						})
					}
				})
			}
		},
		filters: {
			transferTime(val) {
				return dayjs(val).format('YYYY-MM-DD HH:mm:ss')
			}
		}
	}
</script>

<style lang="scss">
	.order-content {
		font-size: 28rpx;
		width: 750rpx;
		background-color: #fff;
		margin-bottom: 135rpx;
		padding-left: 20rpx;
		padding-top: 30rpx;
		margin-bottom: 20rpx;

		.content-item {
			// height: 72rpx;
			padding: 20rpx 20rpx 20rpx 0;
			display: flex;
			align-items: center;

			.item-name {
				width: 200rpx;
				margin-right: 20rpx;
			}
		}

		.content-img {
			width: 100%;
			height: 280rpx;
			display: flex;
			margin-top: 40rpx;

			.img-item {
				width: 220rpx;
				height: 220rpx;
				margin-right: 10rpx;

				image {
					width: 100%;
					height: 100%;
				}

				&:last-child {
					margin-right: 0;
				}
			}
		}

		.detail-item {
			width: 750rpx;
			height: 88rpx;
			display: flex;
			line-height: 88rpx;
			// padding-left: 20rpx;
			background-color: #fff;
			border-bottom: 2rpx solid #f5f5f5;

			.left {
				margin-right: 37rpx;
			}

			.sign {
				width: 115rpx;
				height: 88rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.name {
				margin-right: 26rpx;
			}
		}
	}

	.approve-btn {
		height: 90rpx;
		color: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		background-color: $theme-color;
	}
</style>
